﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algorithms
{
    public class Point2D : IComparable
    {
        private double _x;
        private double _y;
        public Point2D(double x, double y)
        {
            this._x = x;
            this._y = y;
        }

        public double x()
        {
            return this._x;
        }

        public double y()
        {
            return this._y;
        }

        public int CompareTo(object obj)
        {
            Point2D that = obj as Point2D;
            if (that == null)
            {
                throw new ArgumentException();
            }

            if (this.y() < that.y()) return -1;
            if (this.y() > that.y()) return +1;
            if (this.x() < that.x()) return -1;
            if (this.x() > that.x()) return +1;
            return 0;
        }

        public override string ToString()
        {
            return string.Format("({0:F6},{1:F6})", _x, _y);

        }
    }
}
